//
//  PwdModifyAlertView.m
//  X-Touch2
//
//  Created by shengchao yang on 12-4-26.
//  Copyright (c) 2012年 foxhis. All rights reserved.
//

#import "PwdModifyAlertView.h"

@implementation PwdModifyAlertView

-(id)initWithTitle:(NSString *)title message:(NSString *)message delegate:(id)delegate cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSString *)otherButtonTitles, ...{
    self = [super initWithTitle:title message:message delegate:delegate cancelButtonTitle:cancelButtonTitle otherButtonTitles:otherButtonTitles,nil];
    if(self){
        UITextField * oldPwd = [[UITextField alloc] initWithFrame:CGRectMake(22, 45, 240, 36)];
        oldPwd.tag = TagOfUITextField;
        oldPwd.placeholder = @"旧密码";
        oldPwd.secureTextEntry = YES;
        oldPwd.backgroundColor = [UIColor whiteColor];
        oldPwd.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
        [self addSubview:oldPwd];
        [oldPwd release];
        
        UITextField * newPwd = [[UITextField alloc] initWithFrame:CGRectMake(22, 90, 240, 36)];
        newPwd.tag = TagOfUITextField + 1;
        newPwd.placeholder = @"新密码";
        newPwd.secureTextEntry = YES;
        newPwd.backgroundColor = [UIColor whiteColor];
        newPwd.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
        [self addSubview:newPwd];
        [newPwd release];
        
        UITextField * cfmPwd = [[UITextField alloc] initWithFrame:CGRectMake(22, 135, 240, 36)];
        cfmPwd.tag = TagOfUITextField + 2;
        cfmPwd.placeholder = @"确认新密码";
        cfmPwd.secureTextEntry = YES;
        cfmPwd.backgroundColor = [UIColor whiteColor];
        cfmPwd.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
        [self addSubview:cfmPwd];
        [cfmPwd release];
    }
    return self;    
}

-(void)layoutSubviews{
    //扩展AlertView的高度(注意：这里只能改self.bounds的height！如果改self.frame的话界面初始化会闪烁一次)
    CGRect bounds = self.bounds;
    bounds.size.height = 260;
    self.bounds = bounds;
    
    for (UIView *view in self.subviews) {
        //搜索AlertView底部按钮，然后将其位置下移
        //IOS5之前是UIButton,IOS5是UIThreePartButton
        if ([view isKindOfClass:[UIButton class]] || [view isKindOfClass:NSClassFromString(@"UIThreePartButton")]) {
            CGRect btnBounds = view.frame;
            btnBounds.origin.y = 170 + 7;
            view.frame = btnBounds;
        }
    }
}
@end
